#ifndef MQTTCLIENT_H
#define MQTTCLIENT_H

#include <QObject>
#include <qmqtt.h>
class MqttClient : public QObject
{
    Q_OBJECT
public:
    explicit MqttClient(QString ip, int portnum=1883, QObject *parent = nullptr);
    void start();
private:
    QString hostname;                                   //主机地址
    int port;                                           //端口
    QMQTT::Client *client;                              //QMQTT对象
signals:

public slots:
    void mqttconnected();                               //连接完成
    void mqttdisconnected();                            //断开连接
    void mqtterror(const QMQTT::ClientError error);     //连接错误
    void mqttreadyread(const QMQTT::Message &msg);      //有数据可读
};

#endif // MQTTCLIENT_H
